﻿using BootstrapBlazor.Components;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.AspNetCore.Components.Routing;
using System.Diagnostics.CodeAnalysis;

namespace BootstrapBlazor.OnlyServerZhongShun.Components.Shared
{
    /// <summary>
    /// 
    /// </summary>
    public sealed partial class MainLayout
    {
        private bool UseTabSet { get; set; } = true;

        private string Theme { get; set; } = "";

        private bool IsOpen { get; set; }

        private bool IsFixedHeader { get; set; } = true;

        private bool IsFixedFooter { get; set; } = true;

        private bool IsFullSide { get; set; } = true;

        private bool ShowFooter { get; set; } = true;

        private List<MenuItem>? Menus { get; set; }

        //当前用户名
        private string username { get; set; }

        [Inject]
        [NotNull]
        private AuthenticationStateProvider? authenticationStateProvider { get; set; }
        /// <summary>
        /// OnInitialized 方法
        /// </summary>
        protected async override void OnInitialized()
        {
            base.OnInitialized();
            //获取用户名
            var authState = await authenticationStateProvider.GetAuthenticationStateAsync();
            var user = authState.User;
            username = user.Identity.Name;

            Menus = GetIconSideMenuItems();
        }

        private static List<MenuItem> GetIconSideMenuItems()
        {
            var menus = new List<MenuItem>
            {
                new() { Text = "首页", Icon = "fa-solid fa-fw fa-flag", Url = "/index" , Match = NavLinkMatch.All},
                //new() { Text = "Counter", Icon = "fa-solid fa-fw fa-check-square", Url = "/counter" },
                //new() { Text = "Weather", Icon = "fa-solid fa-fw fa-database", Url = "/weather" },
                //new() { Text = "Table", Icon = "fa-solid fa-fw fa-table", Url = "/table" },
                //new() { Text = "花名册", Icon = "fa-solid fa-fw fa-users", Url = "/users" },
                //new() { Text = "业务总表", Icon = "fa-solid fa-fw fa-users", Url = "/业务总表" ,Match = Microsoft.AspNetCore.Components.Routing.NavLinkMatch.All},
                new() { Text = "业务发货总表", Icon = "fa-solid fa-fw fa-users", Url = "/业务总表当月" ,Match = Microsoft.AspNetCore.Components.Routing.NavLinkMatch.All},
                new() { Text = "客户发货排名表", Icon = "fa-solid fa-fw fa-users", Url = "/Form1" },
                new() { Text = "业务员发货排名表", Icon = "fa-solid fa-fw fa-users", Url = "/Form2" },
                new() { Text = "部门发货排名表", Icon = "fa-solid fa-fw fa-users", Url = "/部门发货排名" },
                new() { Text = "产品渠道对应表", Icon = "fa-solid fa-fw fa-users", Url = "/Form3" },
                new() { Text = "发货有效率分析表", Icon = "fa-solid fa-fw fa-users", Url = "/Form4" },

                new() { Text = "发货状况分析表", Icon = "fa-solid fa-fw fa-users", Url = "/Form6" },
                new() { Text = "门店销售分析表", Icon = "fa-solid fa-fw fa-users", Url = "/Form7" },
                new() { Text = "门店进销存明细表", Icon = "fa-solid fa-fw fa-users", Url = "/门店销售按产品分析表" },
                new() { Text = "门店客户分析表", Icon = "fa-solid fa-fw fa-users", Url = "/Form8" },
                new() { Text = "业务经营月度报表", Icon = "fa-solid fa-fw fa-users", Url = "/Form9" },
                new() { Text = "产品渠道年度对应表", Icon = "fa-solid fa-fw fa-users", Url = "/Form10" },
                new() { Text = "POS-U8门店对照表", Icon = "fa-solid fa-fw fa-users", Url = "/T客商门店对照" },
                new() { Text = "POS-U8存货对照表", Icon = "fa-solid fa-fw fa-users", Url = "/POSU8InvPrice" }

            };

            return menus;
        }
    }
}
